package com.sx.zongzhi.presenter;

import android.content.Context;

import com.sx.zongzhi.bean.UserBean;
import com.sx.zongzhi.modle.ApiManager;
import com.sx.zongzhi.modle.HeadParamBean;
import com.sx.zongzhi.net.BaseCallBack;
import com.sx.zongzhi.net.BaseResult;
import com.sx.zongzhi.voiceamr.UpdatePersonView;

import java.util.Map;

/**修改个人用户信息
 * Created by admin on 2017/12/4.
 */

public class UpdatePersonInfoPest {
    public UpdatePersonView updatePersonView;

    public UpdatePersonInfoPest(UpdatePersonView updatePersonView) {
        this.updatePersonView = updatePersonView;
    }
    public void updatePerson(Context context,String userId,String name,
                             String mobile, String headerUrl){
        Map<String,Object> map = HeadParamBean.getHead(context);
        map.put("user.id",userId);
        map.put("user.name", name);
        map.put("user.mobile", mobile);
        map.put("user.headerUrl",headerUrl);
        new ApiManager().updatePerson(map, new BaseCallBack<BaseResult<UserBean>>() {
            @Override
            public void onSuccess(BaseResult<UserBean> response) {
                updatePersonView.updatePersonSuccess(response.getData());
            }
            @Override
            public void onFailures(String message) {
                updatePersonView.showError(message);
            }
        });
    }

    public void updatePassword(Context context,String oldPassword,String currentPassword,
                             String validatePassword){
        Map<String,Object> map = HeadParamBean.getHead(context);
        map.put("oldPassword",oldPassword);
        map.put("currentPassword", currentPassword);
        map.put("validatePassword", validatePassword);
        new ApiManager().updatePassword(map, new BaseCallBack<BaseResult<UserBean>>() {
            @Override
            public void onSuccess(BaseResult<UserBean> response) {
                updatePersonView.updatePersonSuccess(response.getData());
            }
            @Override
            public void onFailures(String message) {
                updatePersonView.showError(message);
            }
        });
    }
}
